package edu.zli.register;

import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;

/**
 * @Desc
 * @Author Zerlinda
 * @Date 2022/5/7 14:26
 * @Version 1.0
 */
public class EnumSingletonReflectTest {
    public static void main(String[] args) throws NoSuchMethodException, InvocationTargetException, InstantiationException, IllegalAccessException {
        Class<?> clazz = EnumSingleton.class;

        Constructor c = clazz.getDeclaredConstructor(String.class, int.class);
        c.setAccessible(true);

        // Cannot reflectively create enum objects
        // 不能用反射创建枚举对象
        Object o = c.newInstance("INSTANCE", 0);

        System.out.println(c);
    }
}
